package com.indusfo.spc.controller;

import com.indusfo.spc.pojo.MatDete;
import com.indusfo.spc.service.MatDeteService;
import com.indusfo.spc.vo.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @Author liub
 * @Date 2019/11/22 17:42
 * @Version 1.0
 */

@Controller
@RequestMapping("/service/matDete")
public class MatDeteController {

    @Autowired
    private MatDeteService matDeteService;

    /**
     * 查询
     */
    @RequestMapping(value = "/queryMatDete")
    @ResponseBody
    public JSONObject queryMatDete(MatDete matDete) {
        JSONObject json = matDeteService.queryMatDete(matDete);
        return json;
    }

    /**
     * 新增
     */
    @RequestMapping(value = "/insertMatDete", method = RequestMethod.POST)
    @ResponseBody
    public JSONObject insertMatDete(MatDete matDete) {
        JSONObject json = matDeteService.insertMatDete(matDete);
        return json;
    }

    /**
     * 修改
     */
    @RequestMapping(value = "/updateMatDete", method = RequestMethod.POST)
    @ResponseBody
    public JSONObject updateMatDete(MatDete matDete) {
        JSONObject json = matDeteService.updateMatDete(matDete);
        return json;
    }

    /**
     * 删除
     */
    @RequestMapping(value = "/deleteMatDete", method = RequestMethod.POST)
    @ResponseBody
    public JSONObject deleteMatDete(@RequestParam("matDeteIds") List<Integer> matDeteIds, Integer dataState) {
        dataState = 2;
        JSONObject json = matDeteService.deleteMatDete(matDeteIds, dataState);
        return json;
    }

    /**
     * 启停
     */
    @RequestMapping(value = "/definedMatDete", method = RequestMethod.POST)
    @ResponseBody
    public JSONObject definedMatDete(@RequestParam("matDeteIds") List<Integer> matDeteIds, Integer dataState) {
        JSONObject json = matDeteService.deleteMatDete(matDeteIds, dataState);
        return json;
    }
}
